import { reqNotice } from "@/api";
import { Message } from "element-ui";
export  default({
    namespaced:true,
    actions:{
        async getNotices(context){
           let result= await reqNotice();
           if(result.code==='200'){
            context.commit('getNotices',result.other);
           }else{
                Message({
                    message: '警告!'+'['+result.code+']'+'['+result.message+']',
                    type: 'warning'
                })
                return;
           }
        }
    },
    mutations:{
        getNotices(state,value){
            state.notices=value;
        }
    },
    state:{
        notices:[]
    },
    getters:{
        noticeFirst(state){
            //当公告列表不为空传递数组第一个对象，反之传递空对象
           return state.notices[0]||{};
        }
    }
})